package com.cencat.route.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 路线发票实体类
 * 
 * @author cencat
 * @since 2024-01-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("route_invoice")
public class RouteInvoice implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 发票ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 发票编号
     */
    @NotBlank(message = "发票编号不能为空")
    @Size(max = 50, message = "发票编号长度不能超过50个字符")
    @TableField("invoice_code")
    private String invoiceCode;

    /**
     * 路线ID
     */
    @NotNull(message = "路线ID不能为空")
    @TableField("route_id")
    private Long routeId;

    /**
     * 订单ID
     */
    @NotNull(message = "订单ID不能为空")
    @TableField("order_id")
    private Long orderId;

    /**
     * 商户ID
     */
    @NotNull(message = "商户ID不能为空")
    @TableField("merchant_id")
    private Long merchantId;

    /**
     * 司机ID
     */
    @TableField("driver_id")
    private Long driverId;

    /**
     * 发票类型：1-普通发票，2-专用发票，3-电子发票
     */
    @NotNull(message = "发票类型不能为空")
    @TableField("invoice_type")
    private Integer invoiceType;

    /**
     * 发票抬头
     */
    @NotBlank(message = "发票抬头不能为空")
    @Size(max = 200, message = "发票抬头长度不能超过200个字符")
    @TableField("invoice_title")
    private String invoiceTitle;

    /**
     * 纳税人识别号
     */
    @Size(max = 50, message = "纳税人识别号长度不能超过50个字符")
    @TableField("tax_number")
    private String taxNumber;

    /**
     * 开票日期
     */
    @NotNull(message = "开票日期不能为空")
    @TableField("invoice_date")
    private LocalDateTime invoiceDate;

    /**
     * 发票金额(不含税)
     */
    @NotNull(message = "发票金额不能为空")
    @DecimalMin(value = "0.01", message = "发票金额必须大于0")
    @Digits(integer = 10, fraction = 2, message = "发票金额格式不正确")
    @TableField("invoice_amount")
    private BigDecimal invoiceAmount;

    /**
     * 税率(%)
     */
    @NotNull(message = "税率不能为空")
    @DecimalMin(value = "0.00", message = "税率不能为负数")
    @DecimalMax(value = "100.00", message = "税率不能超过100%")
    @Digits(integer = 3, fraction = 2, message = "税率格式不正确")
    @TableField("tax_rate")
    private BigDecimal taxRate;

    /**
     * 税额
     */
    @NotNull(message = "税额不能为空")
    @DecimalMin(value = "0.00", message = "税额不能为负数")
    @Digits(integer = 10, fraction = 2, message = "税额格式不正确")
    @TableField("tax_amount")
    private BigDecimal taxAmount;

    /**
     * 价税合计
     */
    @NotNull(message = "价税合计不能为空")
    @DecimalMin(value = "0.01", message = "价税合计必须大于0")
    @Digits(integer = 10, fraction = 2, message = "价税合计格式不正确")
    @TableField("total_amount")
    private BigDecimal totalAmount;

    /**
     * 货物或应税劳务名称
     */
    @NotBlank(message = "货物或应税劳务名称不能为空")
    @Size(max = 200, message = "货物或应税劳务名称长度不能超过200个字符")
    @TableField("goods_name")
    private String goodsName;

    /**
     * 规格型号
     */
    @Size(max = 100, message = "规格型号长度不能超过100个字符")
    @TableField("specification")
    private String specification;

    /**
     * 单位
     */
    @Size(max = 20, message = "单位长度不能超过20个字符")
    @TableField("unit")
    private String unit;

    /**
     * 数量
     */
    @DecimalMin(value = "0.01", message = "数量必须大于0")
    @Digits(integer = 10, fraction = 2, message = "数量格式不正确")
    @TableField("quantity")
    private BigDecimal quantity;

    /**
     * 单价
     */
    @DecimalMin(value = "0.01", message = "单价必须大于0")
    @Digits(integer = 10, fraction = 2, message = "单价格式不正确")
    @TableField("unit_price")
    private BigDecimal unitPrice;

    /**
     * 销售方名称
     */
    @NotBlank(message = "销售方名称不能为空")
    @Size(max = 200, message = "销售方名称长度不能超过200个字符")
    @TableField("seller_name")
    private String sellerName;

    /**
     * 销售方纳税人识别号
     */
    @NotBlank(message = "销售方纳税人识别号不能为空")
    @Size(max = 50, message = "销售方纳税人识别号长度不能超过50个字符")
    @TableField("seller_tax_number")
    private String sellerTaxNumber;

    /**
     * 销售方地址电话
     */
    @Size(max = 200, message = "销售方地址电话长度不能超过200个字符")
    @TableField("seller_address_phone")
    private String sellerAddressPhone;

    /**
     * 销售方开户行及账号
     */
    @Size(max = 200, message = "销售方开户行及账号长度不能超过200个字符")
    @TableField("seller_bank_account")
    private String sellerBankAccount;

    /**
     * 购买方地址电话
     */
    @Size(max = 200, message = "购买方地址电话长度不能超过200个字符")
    @TableField("buyer_address_phone")
    private String buyerAddressPhone;

    /**
     * 购买方开户行及账号
     */
    @Size(max = 200, message = "购买方开户行及账号长度不能超过200个字符")
    @TableField("buyer_bank_account")
    private String buyerBankAccount;

    /**
     * 发票状态：1-待开票，2-已开票，3-已作废，4-已红冲
     */
    @NotNull(message = "发票状态不能为空")
    @TableField("invoice_status")
    private Integer invoiceStatus;

    /**
     * 开票人
     */
    @Size(max = 50, message = "开票人长度不能超过50个字符")
    @TableField("drawer")
    private String drawer;

    /**
     * 复核人
     */
    @Size(max = 50, message = "复核人长度不能超过50个字符")
    @TableField("reviewer")
    private String reviewer;

    /**
     * 收款人
     */
    @Size(max = 50, message = "收款人长度不能超过50个字符")
    @TableField("payee")
    private String payee;

    /**
     * 发票文件路径
     */
    @Size(max = 500, message = "发票文件路径长度不能超过500个字符")
    @TableField("invoice_file_path")
    private String invoiceFilePath;

    /**
     * 发票二维码
     */
    @Size(max = 500, message = "发票二维码长度不能超过500个字符")
    @TableField("qr_code")
    private String qrCode;

    /**
     * 机器编号
     */
    @Size(max = 50, message = "机器编号长度不能超过50个字符")
    @TableField("machine_code")
    private String machineCode;

    /**
     * 发票校验码
     */
    @Size(max = 50, message = "发票校验码长度不能超过50个字符")
    @TableField("check_code")
    private String checkCode;

    /**
     * 作废原因
     */
    @Size(max = 500, message = "作废原因长度不能超过500个字符")
    @TableField("void_reason")
    private String voidReason;

    /**
     * 作废时间
     */
    @TableField("void_time")
    private LocalDateTime voidTime;

    /**
     * 红冲原因
     */
    @Size(max = 500, message = "红冲原因长度不能超过500个字符")
    @TableField("red_rush_reason")
    private String redRushReason;

    /**
     * 红冲时间
     */
    @TableField("red_rush_time")
    private LocalDateTime redRushTime;

    /**
     * 原发票ID(红冲时使用)
     */
    @TableField("original_invoice_id")
    private Long originalInvoiceId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建人ID
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private Long createBy;

    /**
     * 更新人ID
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;

    /**
     * 是否删除：0-未删除，1-已删除
     */
    @TableLogic
    @TableField("is_deleted")
    private Integer isDeleted;

    /**
     * 版本号(乐观锁)
     */
    @Version
    @TableField("version")
    private Integer version;

    /**
     * 备注
     */
    @Size(max = 500, message = "备注长度不能超过500个字符")
    @TableField("remark")
    private String remark;
}